/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bice.service;

import com.bice.dao.Dao;
import com.bice.dao.IEntity;
import java.io.Serializable;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;

/**
 *
 * @author sirius
 */
@Service
public class GenericService<T extends IEntity> {
    
    @Resource
    private Dao<T, Serializable> dao;

    public GenericService() {
    }
    
    public void save(T entity) {
        dao.save(entity);
    }
    
    public T get(String name, Serializable id) {
        return dao.get(name, id);
    }
    
    public T get(Class clazz, Serializable id) {
        return dao.get(clazz, id);
    }
    
    public List<T> getEntities(DetachedCriteria criteria, int first, int pageSize) {
        return dao.get(criteria, first, pageSize);
    }
    
    public int count(DetachedCriteria criteria) {
        return dao.count(criteria);
    }
    
}